package com.last;

import com.last.order.IdWorker;
import org.mybatis.spring.annotation.MapperScan;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@EnableDiscoveryClient
@MapperScan("com.last.mapper")
@EnableFeignClients
public class OrderApp {
    public static void main(String[] args) {

        SpringApplication.run(OrderApp.class,args);
    }

    @Bean
    public IdWorker idWorker(){
        return new IdWorker(1,1);
    }

    @Bean
    public RedissonClient redissonClient() {
        Config config = new Config();
//        config.useClusterServers()
//            .setScanInterval(2000)
//            .addNodeAddress("redis://10.0.29.30:6379", "redis://10.0.29.95:6379")
//            .addNodeAddress("redis://10.0.29.205:6379");

        config.useSingleServer().setAddress("redis://www.starry-sky.xyz:7379")
                .setPassword("123456");
                //.setDatabase();

        RedissonClient redisson = Redisson.create(config);

        return redisson;
    }
}
